﻿using MQ.Core.Common;
using MQ.Core.Entity.System;
using MQ.Core.IRepository.System;
using MQ.Core.IService.System;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace MQ.Core.Service.System
{
    public class UserService : IUserService
    {
        private readonly IUserRepository userReposiotry;
        public UserService(IUserRepository userRepository)
        {
            this.userReposiotry = userRepository;
        }
        public void Delete(string ids)
        {
            userReposiotry.Delete(ids);
        }

        public Task DeleteAsync(string ids)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<UserEntity> GetList(string query)
        {
            return userReposiotry.GetList(query);
        }

        public Task<IEnumerable<UserEntity>> GetListAsync(string query)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<UserEntity> GetPageList(Pagination pagination, string query)
        {
            return userReposiotry.GetPageList(pagination, query);
        }

        public Task<IEnumerable<UserEntity>> GetPageListAsync(Pagination pagination, string query)
        {
            throw new NotImplementedException();
        }

        public void Save(UserEntity entity)
        {
            if (entity.Id > 0) userReposiotry.Update(entity);
            else userReposiotry.Add(entity);
        }

        public Task SaveAsync(UserEntity entity)
        {
            if (entity.Id > 0) return userReposiotry.UpdateAsync(entity);
            else return userReposiotry.AddAsync(entity);
        }
    }
}
